Skip to content

fix: support webpack-dev-server 6.x by dropping SockJS instanceof checks - #1046

Merged
pmmmwh merged 3 commits into
pmmmwh:mainfrom
rtm-ctrlz:fix/webpack-dev-server-6-sockjs
Aug 13, 2026
Merged

fix: support webpack-dev-server 6.x by dropping SockJS instanceof checks#1046
pmmmwh merged 3 commits into
pmmmwh:mainfrom
rtm-ctrlz:fix/webpack-dev-server-6-sockjs

Conversation

@rtm-ctrlz

Copy link
Copy Markdown
Contributor

Summary

webpack-dev-server 6.0.0 removed the SockJS client, but sockets/WDSSocket.js still did a static require('webpack-dev-server/client/clients/SockJSClient') and an instanceof check against it. On WDS 6, that module path no longer resolves, so webpack fails to compile with:

Module not found: Error: Package path ./client/clients/SockJSClient is exported from package
./node_modules/webpack-dev-server, but no valid target file was found
  • Detect the active client via duck-typing on client.sock / client.client instead of instanceof checks against imported client classes. This removes the need to require() a module that may not exist, so there's no compile-time warning/error on any supported WDS version, and it works unchanged across WDS 4/5/6.
  • Widened the webpack-dev-server peer dependency range to ^4.8.0 || 5.x || 6.x.
  • Extended the test harness (webpack-dev-server-v6 dev alias, aliasWDSv6.js) and CI matrix to also run against WDS 6.
  • Updated the supported-versions table in the README.

Test plan

  • yarn lint / yarn format:check
  • Unit tests (yarn test --testPathIgnorePatterns conformance)
  • Conformance tests (yarn test conformance) — all 16 tests pass locally against WDS 4, WDS 5, and WDS 6 (WDS_VERSION=4|5|6)

Fixes #1014

@codesandbox

codesandbox Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@rtm-ctrlz rtm-ctrlz closed this Jul 24, 2026
@rtm-ctrlz
rtm-ctrlz force-pushed the fix/webpack-dev-server-6-sockjs branch from 0e0df87 to 257c43a Compare July 24, 2026 23:00
@rtm-ctrlz rtm-ctrlz reopened this Jul 24, 2026
@pethel

pethel commented Jul 30, 2026

Copy link
Copy Markdown

Thank you guys!

@rtm-ctrlz
rtm-ctrlz force-pushed the fix/webpack-dev-server-6-sockjs branch 2 times, most recently from e602458 to 785b4bb Compare August 6, 2026 11:40
WDS 6.0.0 removed the SockJSClient module, which broke WDSSocket.js's
require() of it with a compile-time "Module not found" error. Detect
the active client via duck-typing on `.sock`/`.client` instead of
instanceof checks against imported client classes, which works
unchanged across WDS 4/5/6 and needs no optional require.

Also widen the webpack-dev-server peer range to include 6.x and extend
the test harness/CI matrix to cover it.
@rtm-ctrlz
rtm-ctrlz force-pushed the fix/webpack-dev-server-6-sockjs branch from 785b4bb to 5ae4de6 Compare August 6, 2026 11:44
@robvdl

robvdl commented Aug 13, 2026

Copy link
Copy Markdown

I ran into a CVE against some webpack component, can't remember now.

Anyway I made it work with webpack 6 in the mean time.

package.json:

  "overrides": {
    "@pmmmwh/react-refresh-webpack-plugin": {
      "webpack-dev-server": "^6.0.0"
    }
  },

webpack.config.js

  resolve: {
    alias: {
      'webpack-dev-server/client/clients/SockJSClient$': 'webpack-dev-server/client/clients/WebSocketClient.js',
    },

Probably not wise though. But it cleared the CVE's for the time being until a new release.

@pmmmwh

pmmmwh commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Sorry for taking a while with this; will get this released today!

@pmmmwh
pmmmwh enabled auto-merge (squash) August 13, 2026 11:13
@pmmmwh
pmmmwh merged commit 2015a55 into pmmmwh:main Aug 13, 2026
19 checks passed
@finken2

finken2 commented Aug 18, 2026

Copy link
Copy Markdown

@pmmmwh do you need to manually do something to publish a new version of the library with this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

webpack-dev-server 6.0 dropped support for SockJS

5 participants